<include file="../header" />
<body class="J_scroll_fixed">
<script type="text/javascript">
    $(function() {
        var listArr=<?php echo json_encode($list);?>;
        var list=eval(listArr);

        for(var i=0;i<list.length;i++){
            $("select[name=groupnotifyId]").append("<option value='" + i + "'>" + list[i]["create_time"] + "，" + list[i]["admin_name"] + "，" + list[i]["keyword1"] + "</option>");
        };

        $("select[name=groupnotifyId]").change(function() {
            var id = $("select[name=groupnotifyId]").val();
            $("input[name=url]").val(list[id]["url"]);
            $("input[name=first]").val(list[id]["first"]);
            $("input[name=keyword1]").val(list[id]["keyword1"]);
            $("textarea[name=keyword3]").text(list[id]["keyword3"]);
            $("textarea[name=remark]").text(list[id]["remark"]);
        });

        $("select[name=caseId]").change(function() {
            $("input[name=url]").val("http://{$WEB_HOST}/wechat/case/detail/id/"+$("select[name=caseId]").val());
            $("input[name=keyword1]").val($("select[name=caseId]").find("option:selected").text());
        });

        $("button#send").click(function() {
            var group = $("input[name='group']:checked").val();
            if(group == null) {
                alert("请选择群组");
                return false;
            }
            if(group == 1){
                if($("select[name=enterpriseId]").val() == ""){
                    alert("请选择企业");
                    return false;
                }
                if($("select[name=roleId]").val() == ""){
                    alert("请选择角色");
                    return false;
                }
            }
            if(group == 2){
                if($("input[name=month]").val() == ""){
                    alert("请填写积分月份");
                    return false;
                }
                if($("input[name=point]").val() == ""){
                    alert("请填写积分变更数值");
                    return false;
                }
            }

            if (confirm("确定发送通知？")) {
                $("button#send").hide();
//                $("form").submit();
            } else {
                return false;
            }

        });

        $("input[name=group]").click(function(){
            switch($(this).val()) {
                case '0':
                    $(".tag").show();
                    $(".report").show();
                    $(".enterprise").hide();
                    $(".point").hide();
                    break;
                case '1':
                    $(".tag").hide();
                    $(".report").show();
                    $(".enterprise").show();
                    $(".point").hide();
                    break;
                case '2':
                    $(".tag").hide();
                    $(".report").hide();
                    $(".enterprise").hide();
                    $(".point").show();
                    break;
            }
        });

    })

</script>
<script type="text/javascript"  src="__TMP__/assets/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript"  src="__TMP__/assets/js/ueditor/ueditor.all.min.js"></script>
<div class="wrap jj">
    <div class="common-form">
        <form method="post" class="form-horizontal J_ajaxForm" action="{:U('messagebox/groupnotifyPost')}">
            <fieldset>
                <div class="control-group">
                    <label class="control-label">历史群发：</label>
                    <div class="controls">
                        <select style="width: 800px" name="groupnotifyId">
                            <option value='-1'></option>
                        </select>
                    </div>
                </div>
                <hr class="half-rule">
                <div class="control-group">
                    <label class="control-label">群发对象：</label>
                    <div class="controls">
                        <input class="radio inline" type="radio" name="group" value="0" />全体用户&nbsp&nbsp
                        <input class="radio inline" type="radio" name="group" value="1" />员工&nbsp&nbsp
                        <input class="radio inline" type="radio" name="group" value="2" />马蹄足用户
                    </div>
                </div>
                <div style="display: none" class="control-group tag">
                    <label class="control-label">标签：</label>
                    <div class="controls">
                        <input type="text" class="input" style="height:15px; width: 200px" name="tag" value="" placeholder="标签为空则群发全体">
                    </div>
                </div>
                <div style="display: none" class="control-group enterprise">
                    <label class="control-label">选择企业：</label>
                    <div class="controls">
                        <select style="width:200px" name="enterpriseId"><option value="">请选择</option>{:getEnterpriseSelectOptionHtml(null)}</select>
                    </div>
                </div>
                <div style="display: none" class="control-group enterprise">
                    <label class="control-label">选择角色：</label>
                    <div class="controls">
                        <select style="width:200px" name="roleId"><option value="">请选择</option>{:getRoleSelectOptionHtml(null,1)}</select>
                    </div>
                </div>
                <div style="display: none" class="control-group report">
                    <label class="control-label">消息头：</label>
                    <div class="controls">
                        <input type="text" class="input" style="height:15px; width: 600px" name="first" value="希卫康群发推送">
                    </div>
                </div>
                <div style="display: none" class="control-group report">
                    <label class="control-label">报告名称：</label>
                    <div class="controls">
                        <input type="text" class="input" style="height:15px; width: 600px" name="keyword1" value="">
                    </div>
                </div>
                <div style="display: none" class="control-group report">
                    <label class="control-label">详情链接：</label>
                    <div class="controls">
                        <input type="text" class="input" style="height:15px; width: 600px" name="url" value="http://{$WEB_HOST}/wechat/">
                        <select name="caseId">
                            {:getCaseUrlSelectOptionHtml()}
                        </select>
                    </div>
                </div>
                <div style="display: none" class="control-group report">
                    <label class="control-label">建议说明：</label>
                    <div class="controls">
                        <textarea style="height:5rem; width: 600px;" name="keyword3">点击后可跳转详情页面</textarea>
                    </div>
                </div>
                <div style="display: none" class="control-group report">
                    <label class="control-label">备注内容：</label>
                    <div class="controls">
                        <textarea style="height:5rem; width: 600px;" name="remark"></textarea>
                    </div>
                </div>
                <div style="display: none" class="control-group point">
                    <label class="control-label">积分月份：</label>
                    <div class="controls">
                        <input type="text" class="input" style="height:15px; width: 100px" name="month" value="2020-05" placeholder="例如：2020-05">
                    </div>
                    <label class="control-label">积分变更：</label>
                    <div class="controls">
                        <input type="text" class="input" style="height:15px; width: 100px" name="point" value="50" placeholder="">
                    </div>
                </div>

            </fieldset>
            <div class="form-actions">
                <button type="submit" id="send" class="btn btn-primary btn_submit">确认通知</button>
                <a class="btn" href="__URL__">返回</a>
            </div>
        </form>
    </div>
</div>
<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>